<!-- 设备管理-设备列表页面 -->
<template>
  <div class="app-container" style="margin: 0">
    <px-form v-if="!equipopen" ref="queryRef" class="custom-form-ui" :model="queryParams" :inline="true" label-width="90px">
      <px-form-item label="科室">
        <px-select v-model="queryParams.classCode" placeholder="请选择科室" clearable style="width: 240px" filterable @change="setreceiveCompanyCode">
          <px-option v-for="dict in liquidList" :key="dict.id" :label="dict.itemName" :value="dict.itemValue" />
        </px-select>
      </px-form-item>
      <px-form-item label="系统">
        <px-tree-select
          v-model="queryParams.systemCode"
          clearable
          style="width: 100%"
          placeholder="请选择设备系统（树状图）"
          :props="defaultProps"
          :data="systemList"
          check-strictly="true"
          multiple
          :render-after-expand="false"
          collapse-tags
          collapse-tags-tooltip
          @focus="handleSystemFocus"
        />
      </px-form-item>
      <px-form-item label="指标名称">
        <px-input v-model="queryParams.indicatorName" placeholder="请输入指标名称" style="width: 240px" clearable />
      </px-form-item>
      <px-form-item label="指标级别">
        <px-select v-model="queryParams.indicatorLevel" placeholder="请选择接指标级别" clearable style="width: 240px" filterable>
          <px-option v-for="dict in receiveCompanyList" :key="dict.id" :label="dict.itemName" :value="dict.itemValue" />
        </px-select>
      </px-form-item>
      <px-button style="margin-top: -17px" type="primary" icon="" @click="handleQuery('search')">搜索</px-button>
      <px-button style="margin-top: -17px" icon="" @click="resetQuery">重置</px-button>
    </px-form>

    <px-row v-if="!equipopen" :gutter="10" class="mb8">
      <px-col :span="1.5">
        <px-button v-if="classcode == 'WATER'" v-has="'WATER_SPC_SEETING_ADD'" type="primary" icon="" @click="handleAdd">新增</px-button>
        <px-button v-if="classcode == 'GAS'" v-has="'GAS_SPC_SEETING_ADD'" type="primary" icon="" @click="handleAdd">新增</px-button>
        <px-button v-if="classcode == 'ELECTRICTITY'" v-has="'ELECTRICTITY_SPC_SEETING_ADD'" type="primary" icon="" @click="handleAdd"
          >新增</px-button
        >
        <px-button v-if="classcode == 'MACHINE'" v-has="'MACHINE_SPC_SEETING_ADD'" type="primary" icon="" @click="handleAdd">新增</px-button>
      </px-col>
      <!-- <px-col :span="1.5">
        <px-button type="primary" plain icon="">下载模板</px-button>
      </px-col>
      <px-col :span="1.5">
        <px-button type="primary" plain icon="" :disabled="true" @click="handleExport">批量导入</px-button>
      </px-col> -->

      <!-- <px-col :span="1.5">
        <px-button v-has="'CommonEquipListDelete'" type="danger" plain icon="" :disabled="multiple" @click="handleDelete">删除</px-button>
      </px-col> -->
    </px-row>

    <px-table
      v-if="!equipopen"
      v-loading="loading"
      :data="typeList"
      height="calc(100vh - 319px)"
      show-overflow-tooltip
      border
      @selection-change="handleSelectionChange"
    >
      <!-- <px-table-column type="selection" width="40" /> -->
      <!-- <px-table-column width="200" label="JOB ID" prop="jobId" /> -->
      <px-table-column label="序号" width="60" align="center" fixed="left">
        <template #default="{ $index }">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + $index + 1 }}
        </template>
      </px-table-column>
      <px-table-column label="指标名称" width="230" prop="indicatorName">
        <template #default="scope">
          <span>{{ scope.row.indicatorName }}</span>
        </template>
      </px-table-column>

      <px-table-column label="指标级别" align="center" prop="indicatorLevel">
        <template #default="scope">
          <div v-if="scope.row.indicatorLevel == 'Key-key'" class="level1">{{ scope.row.indicatorLevel }}</div>
          <div v-if="scope.row.indicatorLevel == 'key' || scope.row.indicatorLevel == 'Key'" class="level2">{{ scope.row.indicatorLevel }}</div>
          <div v-if="scope.row.indicatorLevel == 'non-key'" class="level3">{{ scope.row.indicatorLevel }}</div>
        </template>
      </px-table-column>
      <px-table-column label="子系统" width="230" prop="className">
        <template #default="scope">
          <span>{{ scope.row.systemName ? scope.row.systemName : scope.row.systemCode }}</span>
        </template>
      </px-table-column>
      <px-table-column label="绑定点位" width="210" prop="point">
        <template #default="scope">
          <span>{{ scope.row.point }}</span>
        </template>
      </px-table-column>
      <px-table-column label="USL" prop="uslValue">
        <template #heade>
          <span style="display: inline-flex; align-items: center">
            USL
            <px-icon> <Back /> </px-icon
          ></span>
        </template>
        <template #default="scope">
          <span>{{ scope.row.uslValue ? scope.row.uslValue : "-" }}</span>
        </template>
      </px-table-column>
      <px-table-column label="UCL" prop="uclValue">
        <template #header>
          <span style="display: inline-flex; align-items: center">
            UCL
            <px-icon> <Back /> </px-icon
          ></span>
        </template>
        <template #default="scope">
          <span>{{ scope.row.uclValue ? scope.row.uclValue : "-" }}</span>
        </template>
      </px-table-column>
      <px-table-column label="UWL" prop="uwlValue">
        <template #header>
          <span style="display: inline-flex; align-items: center">
            UWL
            <px-icon> <Back /> </px-icon
          ></span>
        </template>
        <template #default="scope">
          <span>{{ scope.row.uwlValue ? scope.row.uwlValue : "-" }}</span>
        </template>
      </px-table-column>
      <px-table-column label="T" prop="targetValue">
        <template #default="scope">
          <span>{{ scope.row.targetValue ? scope.row.targetValue : "-" }}</span>
        </template>
      </px-table-column>
      <px-table-column label="LWL" prop="lwlValue">
        <template #header>
          <span style="display: inline-flex; align-items: center">
            LWL
            <px-icon> <Right /> </px-icon
          ></span>
        </template>
        <template #default="scope">
          <span>{{ scope.row.lwlValue ? scope.row.lwlValue : "-" }}</span>
        </template>
      </px-table-column>
      <px-table-column label="LCL" prop="lclValue">
        <template #header>
          <span style="display: inline-flex; align-items: center">
            LCL
            <px-icon> <Right /> </px-icon
          ></span>
        </template>
        <template #default="scope">
          <span>{{ scope.row.lclValue ? scope.row.lclValue : "-" }}</span>
        </template>
      </px-table-column>
      <px-table-column label="LSL" prop="lslValue">
        <template #header>
          <span style="display: inline-flex; align-items: center">
            LSL
            <px-icon> <Right /> </px-icon
          ></span>
        </template>
        <template #default="scope">
          <span>{{ scope.row.lslValue ? scope.row.lslValue : "-" }}</span>
        </template>
      </px-table-column>
      <px-table-column fixed="right" label="操作" align="center" width="140">
        <template #default="scope">
          <px-button v-if="classcode == 'WATER'" v-has="'WATER_SPC_DETAIL'" link type="primary" @click="handleDetail(scope.row.id)">
            <px-tooltip class="box-item" content="详情" placement="top">
              <px-icon>
                <Tickets />
              </px-icon> </px-tooltip
          ></px-button>
          <px-button v-if="classcode == 'GAS'" v-has="'GAS_SPC_DETAIL'" link type="primary" @click="handleDetail(scope.row.id)">
            <px-tooltip class="box-item" content="详情" placement="top">
              <px-icon>
                <Tickets />
              </px-icon> </px-tooltip
          ></px-button>
          <px-button v-if="classcode == 'ELECTRICTITY'" v-has="'ELECTRICTITY_SPC_DETAIL'" link type="primary" @click="handleDetail(scope.row.id)">
            <px-tooltip class="box-item" content="详情" placement="top">
              <px-icon>
                <Tickets />
              </px-icon> </px-tooltip
          ></px-button>
          <px-button v-if="classcode == 'MACHINE'" v-has="'MACHINE_SPC_DETAIL'" link type="primary" @click="handleDetail(scope.row.id)">
            <px-tooltip class="box-item" content="详情" placement="top">
              <px-icon>
                <Tickets />
              </px-icon> </px-tooltip
          ></px-button>

          <px-button v-if="classcode == 'WATER'" v-has="'WATER_SPC_SEETING'" link type="primary" @click="handleEditor(scope.row.id)">
            <px-tooltip class="box-item" content="编辑" placement="top">
              <px-icon>
                <EditPen />
              </px-icon> </px-tooltip
          ></px-button>
          <px-button v-if="classcode == 'GAS'" v-has="'GAS_SPC_SEETING'" link type="primary" @click="handleEditor(scope.row.id)">
            <px-tooltip class="box-item" content="编辑" placement="top">
              <px-icon>
                <EditPen />
              </px-icon> </px-tooltip
          ></px-button>
          <px-button v-if="classcode == 'ELECTRICTITY'" v-has="'ELECTRICTITY_SPC_SEETING'" link type="primary" @click="handleEditor(scope.row.id)">
            <px-tooltip class="box-item" content="编辑" placement="top">
              <px-icon>
                <EditPen />
              </px-icon> </px-tooltip
          ></px-button>
          <px-button v-if="classcode == 'MACHINE'" v-has="'MACHINE_SPC_SEETING'" link type="primary" @click="handleEditor(scope.row.id)">
            <px-tooltip class="box-item" content="编辑" placement="top">
              <px-icon>
                <EditPen />
              </px-icon> </px-tooltip
          ></px-button>
          <px-button v-if="classcode == 'WATER'" v-has="'WATER_SPC_DELETE'" link type="danger" @click="handleDelete(scope.row)"
            ><px-tooltip class="box-item" content="删除" placement="top">
              <px-icon>
                <Delete />
              </px-icon> </px-tooltip
          ></px-button>
          <px-button v-if="classcode == 'GAS'" v-has="'GAS_SPC_DELETE'" link type="danger" @click="handleDelete(scope.row)"
            ><px-tooltip class="box-item" content="删除" placement="top">
              <px-icon>
                <Delete />
              </px-icon> </px-tooltip
          ></px-button>
          <px-button v-if="classcode == 'ELECTRICTITY'" v-has="'ELECTRICTITY_SPC_DELETE'" link type="danger" @click="handleDelete(scope.row)"
            ><px-tooltip class="box-item" content="删除" placement="top">
              <px-icon>
                <Delete />
              </px-icon> </px-tooltip
          ></px-button>
          <px-button v-if="classcode == 'MACHINE'" v-has="'MACHINE_SPC_DELETE'" link type="danger" @click="handleDelete(scope.row)"
            ><px-tooltip class="box-item" content="删除" placement="top">
              <px-icon>
                <Delete />
              </px-icon> </px-tooltip
          ></px-button>
        </template>
      </px-table-column>
      <template #empty>
        <px-empty :image-size="150" />
      </template>
    </px-table>

    <pagination
      v-if="!equipopen"
      v-show="total > 0"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      style="margin-bottom: -10px"
      :total="total"
      @pagination="getList"
    />

    <!-- 添加或修改参数配置对话框 -->

    <px-scrollbar v-if="equipopen" class="editorEquip">
      <px-button style="margin-left: 24px" type="primary" :icon="ArrowLeft" @click="cancel">返回</px-button>

      <div class="px-descriptions__title" style="margin: 20px 20px 0">
        基本信息
        <span class="time">创建时间：{{ equipdata.createTime }}</span>
      </div>
      <px-row style="padding: 20px">
        <px-col :span="8">
          <px-descriptions class="margin-top" :column="1" border>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">JOB ID</div>
              </template>
              {{ equipdata.jobId }}
            </px-descriptions-item>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">子系统</div>
              </template>
              {{ equipdata.systemName }}
            </px-descriptions-item>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">Y轴最大值</div>
              </template>
              {{ equipdata.endValue }}
            </px-descriptions-item>
          </px-descriptions>
        </px-col>
        <px-col :span="8">
          <px-descriptions class="center2" :column="1" border>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">指标名称</div>
              </template>
              {{ equipdata.indicatorName }}
            </px-descriptions-item>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">系统</div>
              </template>
              {{ equipdata.systemName }}
            </px-descriptions-item>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">Y轴起始值</div>
              </template>
              {{ equipdata.startValue }}
            </px-descriptions-item>
          </px-descriptions>
        </px-col>
        <px-col :span="8">
          <px-descriptions class="margin-top" :column="1" border>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">指标级别</div>
              </template>
              <div v-if="equipdata.indicatorLevel == 'Key-key'" class="level1">{{ equipdata.indicatorLevel }}</div>
              <div v-if="equipdata.indicatorLevel == 'key' || equipdata.indicatorLevel == 'Key'" class="level2">{{ equipdata.indicatorLevel }}</div>
              <div v-if="equipdata.indicatorLevel == 'non-key'" class="level3">{{ equipdata.indicatorLevel }}</div>
            </px-descriptions-item>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">点位</div>
              </template>
              {{ equipdata.point }}
            </px-descriptions-item>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">Y轴步进值</div>
              </template>
              {{ equipdata.step }}
            </px-descriptions-item>
          </px-descriptions>
        </px-col>
      </px-row>
      <div class="px-descriptions__title" style="margin-left: 20px">上下限信息</div>
      <px-row style="padding: 20px">
        <px-col :span="8">
          <px-descriptions class="margin-top" :column="1" border>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">USL值</div>
              </template>
              {{ equipdata.uslValue }}
            </px-descriptions-item>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">UCL值</div>
              </template>
              {{ equipdata.uclValue }}
            </px-descriptions-item>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">UWL值</div>
              </template>
              {{ equipdata.uwlValue }}
            </px-descriptions-item>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">U3L值</div>
              </template>
              {{ equipdata.u3lValue }}
            </px-descriptions-item>
          </px-descriptions>
        </px-col>
        <px-col :span="8">
          <px-descriptions class="center" :column="1" border>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">Target值</div>
              </template>
              {{ equipdata.targetValue }}
            </px-descriptions-item>
          </px-descriptions>
        </px-col>
        <px-col :span="8">
          <px-descriptions class="margin-top" :column="1" border>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">LWL值</div>
              </template>
              {{ equipdata.lwlValue }}
            </px-descriptions-item>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">LCL值</div>
              </template>
              {{ equipdata.lclValue }}
            </px-descriptions-item>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">LSL值</div>
              </template>
              {{ equipdata.lslValue }}
            </px-descriptions-item>
            <px-descriptions-item>
              <template #label>
                <div class="cell-item">L3L值</div>
              </template>
              {{ equipdata.l3lValue }}
            </px-descriptions-item>
          </px-descriptions>
        </px-col>
      </px-row>
    </px-scrollbar>
    <px-scrollbar v-if="equipopenDetail" class="addEquip">
      <px-button style="margin-left: 24px" type="primary" :icon="ArrowLeft" @click="equipopenDetailcancel">返回</px-button>
      <px-form
        ref="detailruleFormRef"
        :disabled="fromdisable"
        :rules="rules"
        :model="equipdata"
        :inline="true"
        class="demo-form-inline"
        label-width="160px"
      >
        <div
          class="box-card1"
          :style="{
            height: jibenxinxiFlg == true ? '' : '42px'
          }"
        >
          <div class="card-header" @click="setqingdanFlg()">
            <div class="card-title">基本信息</div>
            <div class="card-main">
              <px-icon v-if="!jibenxinxiFlg">
                <ArrowDown />
              </px-icon>
              <px-icon v-else>
                <ArrowUp />
              </px-icon>
            </div>
          </div>
          <div class="form-div">
            <px-row>
              <px-col :span="8">
                <px-form-item label="JOB ID">
                  <px-input v-model="equipdata.jobId" style="width: 260px" disabled="true" placeholder="JOB ID为系统生成" clearable /> </px-form-item
              ></px-col>
              <px-col :span="8">
                <px-form-item label="双/单边控制限">
                  <px-checkbox v-model="checked1" label="上单边" size="default" @change="changTop" />
                  <px-checkbox v-model="checked2" label="下单边" size="default" @change="changBottom" />
                </px-form-item>
              </px-col>
              <px-col :span="8">
                <px-form-item label="ocap流程模版">
                  <px-input v-model="equipdata.ocap" style="width: 260px" placeholder="ocap流程模版" clearable /> </px-form-item
              ></px-col>
            </px-row>
            <px-row>
              <px-col :span="8">
                <px-form-item label="指标名称" prop="indicatorName">
                  <px-input v-model="equipdata.indicatorName" style="width: 260px" placeholder="请输入指标名称" clearable />
                </px-form-item>
              </px-col>
              <px-col :span="8">
                <px-form-item label="指标级别" prop="indicatorLevel">
                  <px-select v-model="equipdata.indicatorLevel" placeholder="请选择接指标级别" style="width: 260px" clearable filterable>
                    <px-option v-for="dict in receiveCompanyList" :key="dict.itemValue" :label="dict.itemName" :value="dict.itemValue" />
                  </px-select>
                </px-form-item>
              </px-col>
              <px-col :span="8">
                <px-form-item label="科室" prop="classCode">
                  <px-select
                    v-model="equipdata.classCode"
                    :disabled="buttonTitle == '编辑'"
                    style="width: 260px"
                    placeholder="请选择科室"
                    clearable
                    filterable
                    @change="setreceiveCompanyCode"
                  >
                    <px-option v-for="dict in liquidList" :key="dict.id" :label="dict.itemName" :value="dict.itemValue" />
                  </px-select>
                </px-form-item>
              </px-col>
            </px-row>
            <px-row>
              <px-col :span="8">
                <px-form-item label="系统">
                  <px-tree-select
                    v-model="equipdata.systemCode"
                    clearable
                    style="width: 260px"
                    placeholder="请选择设备系统（树状图）"
                    :props="defaultProps"
                    check-strictly="true"
                    :data="systemList2"
                    :render-after-expand="false"
                    @focus="handleSystemFocus2"
                  />
                </px-form-item>
              </px-col>
              <px-col :span="8">
                <px-form-item label="点位" prop="point">
                  <!-- <px-select
                    v-model="equipdata.point"
                    :disabled="buttonTitle == '编辑'"
                    clearable
                    filterable
                    style="width: 260px"
                    placeholder="请选择点位"
                  >
                    <px-option v-for="dict in pointList" :key="dict.value" :label="dict.pointName" :value="dict.pointName" />
                  </px-select> -->
                  <!-- <px-select v-model="equipdata.point" placeholder="请选择" style="width: 280px" filterable @change="specIdchange">
                    <px-option
                      v-for="dict in specIdList"
                      :key="dict.measureCode"
                      :label="`${dict.measureName}(${dict.measureCode})`"
                      :value="dict.measureCode"
                    />
                  </px-select> -->
                  <px-input v-model="equipdata.point" style="width: 260px" placeholder="请输入点位" clearable /><px-button
                    size="small"
                    style="position: absolute; right: 40px"
                    type="primary"
                    @click="setmeasure()"
                  >
                    选择
                  </px-button>
                </px-form-item>
              </px-col>
              <!-- <px-col :span="8">
                <px-form-item label="点位单位">
                  <px-input v-model="equipdata.pointUnit" style="width: 260px" placeholder="请输入点位单位" clearable /> </px-form-item
              ></px-col> -->
            </px-row>
            <px-row>
              <px-col :span="8">
                <px-form-item label="Y轴起始值" prop="startValue">
                  <px-input-number
                    v-model="equipdata.startValue"
                    controls-position="right"
                    style="width: 260px"
                    placeholder="请输入Y轴起始值"
                    clearable
                  /> </px-form-item
              ></px-col>
              <px-col :span="8">
                <px-form-item label="Y轴步进值" prop="step">
                  <px-input-number
                    v-model="equipdata.step"
                    controls-position="right"
                    style="width: 260px"
                    placeholder="请输入Y轴步进值"
                    clearable
                  /> </px-form-item
              ></px-col>
              <px-col :span="8">
                <px-form-item label="Y轴最大值" prop="startValue">
                  <px-input-number
                    v-model="equipdata.endValue"
                    controls-position="right"
                    style="width: 260px"
                    placeholder="请输入Y轴最大值"
                    clearable
                  /> </px-form-item
              ></px-col>
            </px-row>
          </div>
        </div>

        <div
          class="box-card2"
          :style="{
            height: jiqicanshuFlg == true ? '' : '42px'
          }"
        >
          <div class="card-header" @click="setjiqicanshuFlg()">
            <div class="card-title">上下限设置</div>
            <div class="card-main">
              <px-icon v-if="!jiqicanshuFlg">
                <ArrowDown />
              </px-icon>
              <px-icon v-else>
                <ArrowUp />
              </px-icon>
            </div>
          </div>
          <div class="info-form-content">
            <px-row>
              <px-col :span="8" style="min-height: 216px; border-right: 1px solid #dfdfdf">
                <p class="bian">上单边</p>

                <px-form-item label="USL值" prop="usl">
                  <px-input-number
                    v-model="equipdata.uslValue"
                    style="width: 280px"
                    controls-position="right"
                    :precision="3"
                    :disabled="!checked1"
                    placeholder="请输入USL值"
                    clearable
                  />
                  <px-color-picker v-model="color1" show-alpha :predefine="predefineColors" />
                </px-form-item>
                <px-form-item label="UCL值" prop="ucl">
                  <px-input-number
                    v-model="equipdata.uclValue"
                    style="width: 280px"
                    controls-position="right"
                    :precision="3"
                    :disabled="!checked1"
                    placeholder="请输入UCL值"
                    clearable
                  />
                  <px-color-picker v-model="color2" show-alpha :predefine="predefineColors" />
                </px-form-item>
                <px-form-item label="UWL值" prop="uwl">
                  <px-input-number
                    v-model="equipdata.uwlValue"
                    style="width: 280px"
                    controls-position="right"
                    :precision="3"
                    :disabled="!checked1"
                    placeholder="请输入UWL值"
                    clearable
                  />
                  <px-color-picker v-model="color3" show-alpha :predefine="predefineColors" />
                </px-form-item>
                <div style="width: 100%; height: 1px; margin-bottom: 20px; background: #dfdfdf" />
                <px-form-item label="U3L值">
                  <px-input-number
                    v-model="equipdata.u3lValue"
                    style="width: 280px"
                    controls-position="right"
                    :precision="3"
                    :disabled="!checked1"
                    placeholder="请输入U3L值"
                    clearable
                  />
                </px-form-item>
              </px-col>
              <px-col :span="8" style="border-right: 1px solid #dfdfdf">
                <px-form-item label="自控线上限值" style="margin-top: 30px" prop="uaclValue">
                  <px-input-number
                    v-model="equipdata.uaclValue"
                    style="width: 280px"
                    controls-position="right"
                    :precision="3"
                    placeholder="请输入自控线上限值"
                    clearable
                  />

                  <!-- <px-color-picker v-model="colortar" show-alpha :predefine="predefineColors" /> -->
                </px-form-item>
                <px-form-item label="Target值" style="margin-top: 30px" prop="target">
                  <px-input-number
                    v-model="equipdata.targetValue"
                    style="width: 280px"
                    controls-position="right"
                    :precision="3"
                    placeholder="请输入Target值"
                    clearable
                  />

                  <px-color-picker v-model="colortar" show-alpha :predefine="predefineColors" />
                </px-form-item>
                <px-form-item label="自控线下限值" style="margin-top: 30px" prop="laclValue">
                  <px-input-number
                    v-model="equipdata.laclValue"
                    style="width: 280px"
                    controls-position="right"
                    :precision="3"
                    placeholder="自控线下限值"
                    clearable
                  />

                  <!-- <px-color-picker v-model="colortar" show-alpha :predefine="predefineColors" />  -->
                </px-form-item></px-col
              >
              <px-col :span="8">
                <p class="bian">下单边</p>
                <px-form-item label="LWL值" prop="lwl">
                  <px-input-number
                    v-model="equipdata.lwlValue"
                    style="width: 280px"
                    controls-position="right"
                    :precision="3"
                    :disabled="!checked2"
                    placeholder="请输入LWL值"
                    clearable
                  />

                  <px-color-picker v-model="color4" show-alpha :predefine="predefineColors" />
                </px-form-item>
                <px-form-item label="LCL值" prop="lcl">
                  <px-input-number
                    v-model="equipdata.lclValue"
                    style="width: 280px"
                    controls-position="right"
                    :precision="3"
                    :disabled="!checked2"
                    placeholder="请输入LCL值"
                    clearable
                  />

                  <px-color-picker v-model="color5" show-alpha :predefine="predefineColors" />
                </px-form-item>
                <px-form-item label="LSL值" prop="lsl">
                  <px-input-number
                    v-model="equipdata.lslValue"
                    style="width: 280px"
                    controls-position="right"
                    :precision="3"
                    :disabled="!checked2"
                    placeholder="请输入LSL值"
                    clearable
                  />

                  <px-color-picker v-model="color6" show-alpha :predefine="predefineColors" />
                </px-form-item>
                <div style="width: 100%; height: 1px; margin-bottom: 20px; background: #dfdfdf" />
                <px-form-item label="L3L值">
                  <px-input-number
                    v-model="equipdata.l3lValue"
                    style="width: 280px"
                    controls-position="right"
                    :precision="3"
                    :disabled="!checked2"
                    placeholder="请输入L3L值"
                    clearable
                  />
                </px-form-item>
              </px-col>
            </px-row>
          </div>
        </div>
      </px-form>

      <px-button type="primary" plain style="margin-bottom: 20px; margin-left: calc(50% - 30px)" @click="spcVisible = true">预览</px-button>
    </px-scrollbar>

    <div v-if="equipopenDetail" class="px-dialog-footer">
      <px-button @click="equipopenDetailcancel">取消</px-button>
      <px-button v-if="fromdisable" type="primary" @click="equipopenDetailcancel">关闭</px-button>
      <px-button v-else type="primary" @click="equipopenDetailsubmitForm(detailruleFormRef)">保存</px-button>
    </div>
    <px-dialog v-model="spcVisible" draggable clickHideContent title="SPC上下限预览" width="800" style="height: 500px" align-center>
      <chartsUpw
        :color="'#3B82F6'"
        :name="equipdata.indicatorName"
        :startValue="equipdata.startValue"
        :step="equipdata.step"
        :usl="equipdata.uslValue"
        :ucl="equipdata.uclValue"
        :uwl="equipdata.uwlValue"
        :target="equipdata.targetValue"
        :lwl="equipdata.lwlValue"
        :lcl="equipdata.lclValue"
        :lsl="equipdata.lslValue"
        :uaclValue="equipdata.uaclValue"
        :laclValue="equipdata.laclValue"
        :width="'750px'"
        :height="'400px'"
      />
    </px-dialog>
    <measure v-if="measureShow" :classcode="classcode" @close="measureclose" @setmeasure="setmeasureValue" />
  </div>
</template>

<script setup name="Dict" lang="ts">
// import useDictStore from '@/store/modules/dict'
defineOptions({
  name: "SystemDataDict"
});
// import { router } from "@/router";
import { ArrowLeft } from "@px-ui/icons-vue";
import { useRoute } from "vue-router";
import { PxMessage, PxMessageBox } from "px-ui";
import { getCurrentInstance, ref, toRefs, reactive, onMounted } from "vue";
import { getToken } from "@/utils/auth";
import { getModuleName } from "@/api/equip/spareParts";
import chartsUpw from "../components/chartsUpw.vue";
import { queryChildByTypeCodeAndItemValue } from "@/api/waterClass";
import { spcqueryList, spcadd, spcupdate, spcqueryDetail, spcdelete, twinPointpageTwinPoint } from "@/api/spc";
import { pageMeasureList } from "@/api/system/measure";
import { querySystemSelect } from "@/api/equip/archive";
import measure from "@/views/water/byOnDuty/watchMeterReading/components/measure.vue";
const props = defineProps({
  classcode: {
    type: String,
    default: ""
  }
});
const jibenxinxiFlg = ref(true);
const defaultTime: [Date, Date] = [new Date(2000, 1, 1, 0, 0, 1), new Date(2000, 1, 1, 23, 59, 59)];
const setqingdanFlg = () => {
  jibenxinxiFlg.value = !jibenxinxiFlg.value;
};
const color1 = ref("#A600FF");
const color2 = ref("#FF0000");
const color3 = ref("#FF9900");
const colortar = ref("#00E272");
const color4 = ref("#FF9900");
const color5 = ref("#FF0000");
const color6 = ref("#A600FF");
const predefineColors = ref(["#ff4500", "#ff8c00", "#ffd700", "#90ee90", "#00ced1", "#1e90ff", "#c71585", "#c71585"]);
const jiqicanshuFlg = ref(true);
const checked1 = ref(true);
const checked2 = ref(true);
const setjiqicanshuFlg = () => {
  jiqicanshuFlg.value = !jiqicanshuFlg.value;
};
const shebeitaizhangFlg = ref(true);
const setshebeitaizhangFlg = () => {
  shebeitaizhangFlg.value = !shebeitaizhangFlg.value;
};
const moxingshezhiFlg = ref(true);
const setmoxingshezhiFlg = () => {
  moxingshezhiFlg.value = !moxingshezhiFlg.value;
};
const specIdchange = val => {
  console.log(val);
  if (val) {
    equipdata.value.pointUnit = specIdList.value.filter(item => item.measureCode == val)[0].measureUnit;
  }
};
const setreceiveCompanyCode = val => {
  let setvalue = null;
  setvalue = liquidList.value.find(option => option.itemValue == val);
  if (setvalue && setvalue?.itemDesc != "") {
    queryParams.value.receiveCompanyCode = JSON.parse(setvalue.itemDesc).receiveCompanyCode;
  } else {
    queryParams.value.receiveCompanyCode = "";
  }
  //console.log(setvalue);
  gettwinPointpageTwinPoint();
};

const setAddreceiveCompanyCode = val => {
  let setvalue = null;
  setvalue = liquidList.value.find(option => option.itemValue == val);
  if (setvalue && setvalue.itemDesc != "") {
    equipdata.value.receiveCompanyCode = JSON.parse(setvalue.itemDesc).receiveCompanyCode;
  } else {
    // equipdata.value.receiveCompanyCode = "";
  }
  //console.log(setvalue);
};
const route = useRoute();
const specIdList = ref([]);
onMounted(() => {
  if (route.query.equipmentId) {
    handleDetail(route.query.equipmentId);
  }
  queryParams.value.classCode = props.classcode;
  getList();
  handleSystemFocus2();
  pageMeasureList({
    measureName: "",
    tagCode: "",
    measureCode: "",
    isNeedCalculate: "",
    measureTypeCode: "",
    createBy: "",
    className: props.classcode,
    measureSource: "",
    isMaintain: "",
    pageNum: 1,
    pageSize: 9999,
    systemCode: ""
  }).then(res => {
    console.log(res);
    specIdList.value = res.data;
  });
});

const { proxy }: any = getCurrentInstance();
const defaultProps = {
  children: "children",
  label: "name",
  value: "code"
};
// 如果有厂区和科室，根据他们的值获取系统
const handleSystemFocus = async () => {
  querySystemSelect({ factoryArea: "", className: queryParams.value.classCode }).then(res => {
    console.log(res[0].children[0].children);
    systemList.value = res[0].children;
  });
};
const handleSystemFocus2 = async () => {
  querySystemSelect({ factoryArea: "", className: queryParams.value.classCode }).then(res => {
    systemList2.value = res[0].children;
  });
};
const typeList = ref([]);
const detailruleFormRef = ref();
const spcVisible = ref(false);
const open = ref(false);
const equipopen = ref(false);
const equipopenDetail = ref(false);
const fromdisable = ref(false);
const loading = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const dateRange = ref([]);
const buttonTitle = ref("");
const data = reactive({
  systemList: [],
  systemList2: [],
  liquidList: [],
  transportCompanyList: [],
  receiveCompanyList: [],
  typeIdList: [],
  categoryList: [],
  equipmentTypeList: [],
  positionList: [],
  equipmentDeptList: [],
  pointList: [],
  modelIdList: [],
  form: {},
  equipdata: {
    id: "",
    jobId: "",
    indicatorName: "",
    classCode: "",
    systemCode: "",
    indicatorLevel: "",
    point: "",
    pointUnit: "",
    step: 0,
    startValue: 0,
    endValue: 0,
    targetValue: 0,
    uclValue: 0,
    lclValue: 0,
    uwlValue: 0,
    lwlValue: 0,
    uslValue: 0,
    lslValue: 0,
    u3lValue: 0,
    l3lValue: 0,
    systemName: "",
    uaclValue: 0,
    laclValue: 0,
    ocap: ""
  },
  queryParams: {
    indicatorName: "",
    classCode: "",
    systemCode: [],
    indicatorLevel: "",
    startTime: "",
    endTime: "",
    pageNum: 1,
    pageSize: 20,
    configType: "SYSTEM"
  },
  rules: {
    indicatorName: [{ required: true, message: "指标名称不能为空", trigger: "blur" }],
    indicatorLevel: [{ required: true, message: "指标级别不能为空", trigger: "change" }],
    classCode: [{ required: true, message: "科室不能为空", trigger: "change" }],
    systemCode: [{ required: true, message: "系统不能为空", trigger: "change" }],
    point: [{ required: true, message: "点位不能为空", trigger: "change" }],
    startValue: [
      {
        validator: (rule: any, value: any, callback: any) => {
          console.log(value);
          if (value === null) {
            return callback(new Error("Y轴起始值不能为空"));
          } else if (equipdata.value.lslValue != null) {
            if (Number(value) >= Number(equipdata.value.lslValue)) {
              return callback(new Error("Y轴起始值必须小于LSL值"));
            }
          }
          callback();
        },
        trigger: "blur",
        required: true
      }
    ],
    endValue: [
      {
        validator: (rule: any, value: any, callback: any) => {
          console.log(value);
          if (value === null) {
            return callback(new Error("Y轴最大值waterConsumable不能为空"));
          } else if (equipdata.value.uslValue != null) {
            if (Number(value) <= Number(equipdata.value.uslValue)) {
              return callback(new Error("Y轴最大值必须大于于USL值"));
            }
          }
          callback();
        },
        trigger: "blur",
        required: true
      }
    ],
    step: [{ required: true, message: "Y轴步进值不能为空", trigger: "blur" }],
    usl: [
      {
        validator: (rule: any, value: any, callback: any) => {
          if (isNumber(equipdata.value.uslValue)) {
            if (equipdata.value.uclValue !== null) {
              if (equipdata.value.uslValue <= equipdata.value.uclValue) {
                return callback(new Error("USL值必须大于UCL值"));
              }
            }
            if (equipdata.value.uwlValue !== null) {
              if (equipdata.value.uslValue <= equipdata.value.uwlValue) {
                return callback(new Error("USL值必须大于UWL值"));
              }
            }
            if (equipdata.value.targetValue !== null) {
              if (equipdata.value.uslValue <= equipdata.value.targetValue) {
                return callback(new Error("USL值必须大于Target值"));
              }
            }
            if (equipdata.value.lwlValue !== null) {
              if (equipdata.value.uslValue <= equipdata.value.lwlValue) {
                return callback(new Error("USL值必须大于LWL值"));
              }
            }
            if (equipdata.value.lclValue !== null) {
              if (equipdata.value.uslValue <= equipdata.value.lclValue) {
                return callback(new Error("USL值必须大于LCL值"));
              }
            }
            if (equipdata.value.lslValue !== null) {
              if (equipdata.value.uslValue <= equipdata.value.lslValue) {
                return callback(new Error("USL值必须大于LSL值"));
              }
            }
          }
          callback();
        },
        trigger: "blur"
      }
    ],
    ucl: [
      {
        validator: (rule: any, value: any, callback: any) => {
          if (isNumber(equipdata.value.uclValue)) {
            if (equipdata.value.uslValue !== null) {
              if (equipdata.value.uslValue <= equipdata.value.uclValue) {
                return callback(new Error("UCL值须小于USL值"));
              }
            }
            if (equipdata.value.uwlValue !== null) {
              if (equipdata.value.uclValue <= equipdata.value.uwlValue) {
                return callback(new Error("UCL值必须大于UWL值"));
              }
            }
            if (equipdata.value.targetValue !== null) {
              if (equipdata.value.uclValue <= equipdata.value.targetValue) {
                return callback(new Error("UCL值必须大于Target值"));
              }
            }
            if (equipdata.value.lwlValue !== null) {
              if (equipdata.value.uclValue <= equipdata.value.lwlValue) {
                return callback(new Error("UCL值必须大于LWL值"));
              }
            }
            if (equipdata.value.lclValue !== null) {
              if (equipdata.value.uclValue <= equipdata.value.lclValue) {
                return callback(new Error("UCL值必须大于LCL值"));
              }
            }
            if (equipdata.value.lslValue !== null) {
              if (equipdata.value.uclValue <= equipdata.value.lslValue) {
                return callback(new Error("UCL值必须大于LSL值"));
              }
            }
          }
          callback();
        },
        trigger: "blur"
      }
    ],
    uwl: [
      {
        validator: (rule: any, value: any, callback: any) => {
          if (isNumber(equipdata.value.uwlValue)) {
            if (equipdata.value.uslValue !== null) {
              if (equipdata.value.uslValue <= equipdata.value.uwlValue) {
                return callback(new Error("UWL值必须小于USL值"));
              }
            }
            if (equipdata.value.uclValue !== null) {
              if (equipdata.value.uclValue <= equipdata.value.uwlValue) {
                return callback(new Error("UWL值必须小于UCL值"));
              }
            }
            if (equipdata.value.targetValue !== null) {
              if (equipdata.value.uwlValue <= equipdata.value.targetValue) {
                return callback(new Error("UWL值必须大于Target值"));
              }
            }
            if (equipdata.value.lwlValue !== null) {
              if (equipdata.value.uwlValue <= equipdata.value.lwlValue) {
                return callback(new Error("UWL值必须大于LWL值"));
              }
            }
            if (equipdata.value.lclValue !== null) {
              if (equipdata.value.uwlValue <= equipdata.value.lclValue) {
                return callback(new Error("UWL值必须大于LCL值"));
              }
            }
            if (equipdata.value.lslValue !== null) {
              if (equipdata.value.uwlValue <= equipdata.value.lslValue) {
                return callback(new Error("UWL值必须大于LSL值"));
              }
            }
          }
          callback();
        },
        trigger: "blur"
      }
    ],
    target: [
      {
        validator: (rule: any, value: any, callback: any) => {
          if (isNumber(equipdata.value.targetValue)) {
            if (equipdata.value.uslValue !== null) {
              if (equipdata.value.uslValue <= equipdata.value.targetValue) {
                return callback(new Error("Target值必须小于USL值"));
              }
            }
            if (equipdata.value.uclValue !== null) {
              if (equipdata.value.uclValue <= equipdata.value.targetValue) {
                return callback(new Error("Target值必须小于UCL值"));
              }
            }
            if (equipdata.value.uwlValue !== null) {
              if (equipdata.value.uwlValue <= equipdata.value.targetValue) {
                return callback(new Error("Target值必须小于UWL值"));
              }
            }
            if (equipdata.value.lwlValue !== null) {
              if (equipdata.value.targetValue <= equipdata.value.lwlValue) {
                return callback(new Error("Target值必须大于LWL值"));
              }
            }
            if (equipdata.value.lclValue !== null) {
              if (equipdata.value.targetValue <= equipdata.value.lclValue) {
                return callback(new Error("Target值必须大于LCL值"));
              }
            }
            if (equipdata.value.lslValue !== null) {
              if (equipdata.value.targetValue <= equipdata.value.lslValue) {
                return callback(new Error("Target值必须大于LSL值"));
              }
            }
          }
          callback();
        },
        trigger: "blur"
      }
    ],
    lwl: [
      {
        validator: (rule: any, value: any, callback: any) => {
          if (isNumber(equipdata.value.lwlValue)) {
            if (equipdata.value.uslValue !== null) {
              if (equipdata.value.uslValue <= equipdata.value.lwlValue) {
                return callback(new Error("LWL值必须小于USL值"));
              }
            }
            if (equipdata.value.uclValue !== null) {
              if (equipdata.value.uclValue <= equipdata.value.lwlValue) {
                return callback(new Error("LWL值必须小于UCL值"));
              }
            }
            if (equipdata.value.uwlValue !== null) {
              if (equipdata.value.uwlValue <= equipdata.value.lwlValue) {
                return callback(new Error("LWL值必须小于UWL值"));
              }
            }
            if (equipdata.value.targetValue !== null) {
              if (equipdata.value.targetValue <= equipdata.value.lwlValue) {
                return callback(new Error("LWL值必须小于Target值"));
              }
            }
            if (equipdata.value.lclValue !== null) {
              if (equipdata.value.lwlValue <= equipdata.value.lclValue) {
                return callback(new Error("LWL值必须大于LCL值"));
              }
            }
            if (equipdata.value.lslValue !== null) {
              if (equipdata.value.lwlValue <= equipdata.value.lslValue) {
                return callback(new Error("LWL值必须大于LSL值"));
              }
            }
          }
          callback();
        },
        trigger: "blur"
      }
    ],
    lcl: [
      {
        validator: (rule: any, value: any, callback: any) => {
          if (isNumber(equipdata.value.lclValue)) {
            if (equipdata.value.uslValue !== null) {
              if (equipdata.value.uslValue <= equipdata.value.lclValue) {
                return callback(new Error("LCL值必须小于USL值"));
              }
            }
            if (equipdata.value.uclValue !== null) {
              if (equipdata.value.uclValue <= equipdata.value.lclValue) {
                return callback(new Error("LCL值必须小于UCL值"));
              }
            }
            if (equipdata.value.uwlValue !== null) {
              if (equipdata.value.uwlValue <= equipdata.value.lclValue) {
                return callback(new Error("LCL值必须小于UWL值"));
              }
            }
            if (equipdata.value.targetValue !== null) {
              if (equipdata.value.targetValue <= equipdata.value.lclValue) {
                return callback(new Error("LCL值必须小于Target值"));
              }
            }
            if (equipdata.value.lwlValue !== null) {
              if (equipdata.value.lwlValue <= equipdata.value.lclValue) {
                return callback(new Error("LCL值必须小于LWL值"));
              }
            }
            if (equipdata.value.lslValue !== null) {
              if (equipdata.value.lclValue <= equipdata.value.lslValue) {
                return callback(new Error("LCL值必须大于LSL值"));
              }
            }
          }
          callback();
        },
        trigger: "blur"
      }
    ],
    lsl: [
      {
        validator: (rule: any, value: any, callback: any) => {
          if (value !== null && value !== undefined) {
            if (isNumber(equipdata.value.lslValue)) {
              if (equipdata.value.uslValue <= equipdata.value.lslValue) {
                return callback(new Error("LSL值必须小于USL值"));
              }
            }
            if (equipdata.value.uclValue !== null) {
              if (equipdata.value.uclValue <= equipdata.value.lslValue) {
                return callback(new Error("LSL值必须小于UCL值"));
              }
            }
            if (equipdata.value.uwlValue !== null) {
              if (equipdata.value.uwlValue <= equipdata.value.lslValue) {
                return callback(new Error("LSL值必须小于UWL值"));
              }
            }
            if (equipdata.value.targetValue !== null) {
              if (equipdata.value.targetValue <= equipdata.value.lslValue) {
                return callback(new Error("LSL值必须小于Target值"));
              }
            }
            if (equipdata.value.lwlValue !== null) {
              if (equipdata.value.lwlValue <= equipdata.value.lslValue) {
                return callback(new Error("LSL值必须小于LWL值"));
              }
            }
            if (equipdata.value.lslValue !== null) {
              if (equipdata.value.lclValue <= equipdata.value.lslValue) {
                return callback(new Error("LSL值必须小于LCL值"));
              }
            }
          }
          callback();
        },
        trigger: "blur"
      }
    ]
  },
  headers: {
    Authorization: "Bearer " + getToken().accessToken || ""
  },
  moduleName: "",
  dialogImageUrl: "",
  imageVisible: false
});

const { liquidList, receiveCompanyList, systemList, systemList2, queryParams, form, rules, equipdata, equipmentTypeList, modelIdList, pointList } =
  toRefs(data);
const isNumber = val => {
  return typeof val === "number";
};

const getqueryCategoryList = () => {
  queryChildByTypeCodeAndItemValue({
    typeCode: "className"
  }).then((response: any) => {
    //console.log(response);
    liquidList.value = response;
  });
  queryChildByTypeCodeAndItemValue({
    typeCode: "SPCL"
  }).then((response: any) => {
    //console.log(response);
    receiveCompanyList.value = response;
  });
};
getqueryCategoryList();
const gettwinPointpageTwinPoint = () => {
  twinPointpageTwinPoint({
    pointGroup: equipdata.value.classCode,
    pageNum: 1,
    pageSize: 1000
  }).then((response: any) => {
    pointList.value = response.data;
  });
};
gettwinPointpageTwinPoint();
function getList() {
  loading.value = true;

  spcqueryList(queryParams.value).then((response: any) => {
    console.log(response);
    typeList.value = response.data;
    total.value = response.total;
    loading.value = false;
  });
}
const measureShow = ref(false);
const setmeasure = () => {
  measureShow.value = true;
};
const measureclose = val => {
  measureShow.value = val;
};
const setmeasureValue = val => {
  measureShow.value = false;
  if (val) {
    equipdata.value.pointUnit = val.measureUnit;
    equipdata.value.point = val.measureCode;
  }
};
/** 取消按钮 */
function cancel() {
  equipopen.value = false;
}
function equipopenDetailcancel() {
  equipopenDetail.value = false;
}
/** 表单重置 */
function reset() {
  form.value = {
    id: undefined,
    dictionaryName: undefined,
    dictionaryType: undefined,
    status: "VALID",
    remarks: undefined
  };
  proxy.resetForm("dictRef");
}
/** 搜索按钮操作 */
function handleQuery(type) {
  if (type == "search") {
    queryParams.value.pageNum = 1;
  }
  getList();
}
/** 重置按钮操作 */
function resetQuery() {
  queryParams.value = {
    pageNum: queryParams.value.pageNum,
    pageSize: queryParams.value.pageSize,
    indicatorName: "",
    classCode: props.classcode,
    systemCode: [],
    indicatorLevel: "",
    startTime: "",
    endTime: "",
    configType: "SYSTEM"
  };
  dateRange.value = [];
  handleQuery("reset");
}

/** 新增按钮操作 */
function handleAdd() {
  buttonTitle.value = "新增";
  jibenxinxiFlg.value = true;
  jiqicanshuFlg.value = true;
  shebeitaizhangFlg.value = true;
  moxingshezhiFlg.value = true;
  equipopenDetail.value = true;
  fromdisable.value = false;
  equipmentTypeList.value = [];
  modelIdList.value = [];
  equipdata.value = {
    id: "",
    jobId: "",
    indicatorName: "",
    classCode: props.classcode,
    systemCode: "",
    indicatorLevel: "",
    point: "",
    pointUnit: "",
    step: null,
    startValue: null,
    endValue: null,
    targetValue: null,
    uclValue: null,
    lclValue: null,
    uwlValue: null,
    lwlValue: null,
    uslValue: null,
    lslValue: null,
    u3lValue: null,
    l3lValue: null,
    systemName: "",
    uaclValue: null,
    laclValue: null,
    ocap: ""
  };
  gettwinPointpageTwinPoint();
}
const handleDetail = async val => {
  jibenxinxiFlg.value = true;
  jiqicanshuFlg.value = true;
  shebeitaizhangFlg.value = true;
  moxingshezhiFlg.value = true;
  const data = await spcqueryDetail({ id: val });
  //console.log(data);

  equipopen.value = true;
  // equipopenDetail.value = true;
  fromdisable.value = true;
  equipdata.value = data;
};

const handleEditor = async val => {
  buttonTitle.value = "编辑";
  jibenxinxiFlg.value = true;
  jiqicanshuFlg.value = true;
  shebeitaizhangFlg.value = true;
  moxingshezhiFlg.value = true;
  checked1.value = true;
  checked2.value = true;
  const data = await spcqueryDetail({ id: val });
  //console.log(data);
  equipopenDetail.value = true;
  fromdisable.value = false;
  equipdata.value = data;
};
/** 多选框选中数据 */
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 提交按钮 */
const changTop = val => {
  if (!val) {
    equipdata.value.uslValue = null;
    equipdata.value.uclValue = null;
    equipdata.value.uwlValue = null;
    equipdata.value.u3lValue = null;
    detailruleFormRef.value.clearValidate();
  }
};
const changBottom = val => {
  if (!val) {
    equipdata.value.lwlValue = null;
    equipdata.value.lclValue = null;
    equipdata.value.lslValue = null;
    equipdata.value.l3lValue = null;
    detailruleFormRef.value.clearValidate();
  }
};
const equipopenDetailsubmitForm = async (formEl: any) => {
  if (!formEl) return;
  await formEl.validate(async valid => {
    if (valid) {
      const params = {
        id: equipdata.value.id,
        jobId: equipdata.value.jobId,
        indicatorName: equipdata.value.indicatorName,
        classCode: equipdata.value.classCode,
        systemCode: equipdata.value.systemCode,
        indicatorLevel: equipdata.value.indicatorLevel,
        point: equipdata.value.point,
        pointUnit: equipdata.value.pointUnit,
        step: equipdata.value.step,
        startValue: equipdata.value.startValue,
        endValue: equipdata.value.endValue,
        targetValue: equipdata.value.targetValue,
        uclValue: equipdata.value.uclValue,
        lclValue: equipdata.value.lclValue,
        uwlValue: equipdata.value.uwlValue,
        lwlValue: equipdata.value.lwlValue,
        uslValue: equipdata.value.uslValue,
        lslValue: equipdata.value.lslValue,
        u3lValue: equipdata.value.u3lValue,
        l3lValue: equipdata.value.l3lValue,
        ocap: equipdata.value.ocap,
        uaclValue: equipdata.value.uaclValue,
        laclValue: equipdata.value.laclValue,
        configType: "SYSTEM"
      };
      if (buttonTitle.value == "新增") {
        spcadd(params).then((response: any) => {
          PxMessage({
            message: `${buttonTitle.value == "新增" ? "添加成功" : "修改成功"}`,
            type: "success"
          });
          resetQuery();
          equipopenDetail.value = false;
        });
      } else {
        spcupdate(params).then((response: any) => {
          PxMessage({
            message: `${buttonTitle.value == "新增" ? "添加成功" : "修改成功"}`,
            type: "success"
          });
          resetQuery();
          equipopenDetail.value = false;
        });
      }
    }
  });
};
/** 删除按钮操作 */
function handleDelete(row) {
  PxMessageBox.confirm(`确认删除${row.indicatorName}？`, "温馨提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
    draggable: true
  })
    .then(async () => {
      const data = await spcdelete({ id: row.id });
      PxMessage({
        message: "删除成功",
        type: "success"
      });
      getList();
    })
    .catch(() => {});
}

/** 导出按钮操作 */
function handleExport() {
  const dictIds = [];
  dictIds.push(...ids.value);
  const params = { ids: dictIds };
  proxy.download("post", "/operation/api/v1/water/generalWaste/liquid/export", params, "一般废液委外台账.xlsx");
}
</script>
<style scoped lang="scss">
.addEquip {
  position: absolute;
  top: 0;
  top: 5px;
  left: 0;
  z-index: 100;
  width: calc(100% - 48px);
  height: calc(100% - 79px);
  margin: 24px;
  background: white;
}

.editorEquip {
  position: absolute;
  top: 0;
  top: 5px;
  left: 0;
  width: calc(100% - 48px);
  height: calc(100% - 40px);
  margin: 24px;
  background: white;
}

.px-dialog-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 999;
  width: 100%;
  height: 50px;
  padding-top: 10px;
  padding-right: 34px;
  text-align: right;
  background: white;
  box-shadow: 0 0 10px 0 rgb(0 0 0 / 16%);
}

.card-header {
  min-height: 40px;
  padding: 14px 15px 7px !important;
  cursor: pointer;
  user-select: none;
  background: #e7eefb;
}

.card-title {
  float: left;
  line-height: 14px;
}

.card-main {
  float: left;
  margin: -3px 8px 0 5px;
  cursor: pointer;
}

.box-card1 {
  width: calc(100% - 48px);
  margin: 24px;
  overflow: hidden;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
}

.box-card2 {
  width: calc(100% - 48px);
  margin: 24px;
  overflow: hidden;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
}

.box-card3 {
  width: calc(100% - 48px);
  height: 163px;
  margin: 24px;
  overflow: hidden;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
}

.box-card4 {
  width: calc(100% - 48px);
  height: 261px;
  margin: 24px;
  overflow: hidden;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
}

.demo-form-inline {
  .px-input {
    --px-input-width: calc(100% - 100px);
  }

  .px-form-item {
    width: 100%;
  }

  .px-textarea__inner {
    width: calc(100% - 100px) !important;
  }

  .px-form-item__label {
    font-weight: 400 !important;
  }
}

.form-div {
  padding: 24px;

  .px-row {
    margin-bottom: 16px;
  }
}

.px-icon {
  font-size: 16px !important;
}

:deep(.px-tabs--top .px-tabs__item.is-top.is-active) {
  border: none;

  .pane-bottom {
    line-height: 30px;
    border-bottom: 2px solid #3b82f6;
  }
}

:deep(.px-tabs .px-tabs__item) {
  .pane-bottom {
    line-height: 30px;
  }
}

.pane-line {
  position: absolute;
  top: 12px;
  right: 0;
  height: 15px;
  color: #dcdcdc;
  border-left: 1px solid #dcdcdc;
}

:deep(.custom-form-ui .px-form-item) {
  width: 250px !important;
}

.filename {
  position: absolute;
  bottom: -30px;
  width: 96px;
  overflow: hidden;
  color: rgb(166 167 172);
  text-overflow: ellipsis;
  white-space: nowrap;
}

:deep(.px-descriptions__label.px-descriptions__cell.is-bordered-label) {
  width: 166px;
  background: #e7eefb;
  border: 1px solid #dfdfdf;
}

:deep(.px-descriptions__body .px-descriptions__table.is-bordered .px-descriptions__cell) {
  border: 1px solid #dfdfdf;
}

.cell-item {
  text-align: right;
}

:deep(.px-table__header) {
  thead {
    tr {
      background-color: #e7eefb !important;

      th {
        font-size: 14px;
        font-weight: bold;
        color: #000;
        background-color: #e7eefb !important;
      }

      th:nth-child(5) {
        background-color: #ccc3dd !important;
      }

      th:nth-child(6) {
        background-color: #ffadad !important;
      }

      th:nth-child(7) {
        background-color: #fff4b7 !important;
      }

      th:nth-child(8) {
        background-color: #b4ffce !important;
      }

      th:nth-child(9) {
        background-color: #fff4b7 !important;
      }

      th:nth-child(10) {
        background-color: #ffadad !important;
      }

      th:nth-child(11) {
        background-color: #ccc3dd !important;
      }

      // th:nth-child(3) {
      //   font-size: 14px;
      //   font-weight: bold;
      //   color: #000;
      //   border-right: none;
      //   background-image: linear-gradient(to right, #0400fc, yellow);
      // }
    }
  }
}

:deep(.px-table--isfixedHeader .px-table__header-wrapper .px-table-fixed-column--right) {
  background-color: #e7eefb !important;
}

.bian {
  line-height: 50px;
  text-align: center;
}

.level1 {
  // width: 52px;
  height: 24px;
  padding: 0 5px;
  margin: 0 auto;
  text-align: center;
  background: #ecfdf5;
  border: 1px solid #10b981;
  border-radius: 4px;
}

.level2 {
  // width: 52px;
  height: 24px;
  padding: 0 5px;
  margin: 0 auto;
  text-align: center;
  background: #fcf6ec;
  border: 1px solid #fda620;
  border-radius: 4px;
}

.level3 {
  // width: 52px;
  height: 24px;
  padding: 0 5px;
  margin: 0 auto;
  text-align: center;
  background: #eff6ff;
  border: 1px solid #3b82f6;
  border-radius: 4px;
}

.center {
  height: 100%;

  :deep(.px-descriptions__body) {
    height: 100%;

    table {
      height: 100% !important;
      border-left: none;

      .is-bordered-label {
        border-left: none !important;
      }

      .is-bordered-content {
        border-right: none !important;
      }
    }
  }
}

.center2 {
  :deep(.px-descriptions__body) {
    table {
      border-left: none;

      .is-bordered-label {
        border-left: none !important;
      }

      .is-bordered-content {
        border-right: none !important;
      }
    }
  }
}

.time {
  float: right;
  font-size: 14px;
  font-weight: 400;
  color: rgb(0 0 0 / 80%);
}
</style>
